<template>
	<view class="content padding" style="padding-bottom: 30upx;">
		<view v-for="item in findList" :key="item.id" style="width: 690upx;flex-direction: column;background-color: #FFFFFF;border-radius: 20upx;padding:20upx 30upx;box-sizing: border-box;margin-top: 30upx;">
			<view style="align-items: center;">
				<image :src="item.userAvatar" mode="" lazy-load style="width: 80upx;height: 80upx;border-radius: 80upx;"></image>
				<view style="margin-left: 20upx;flex-direction: column;">
					<view style="color: #333333;font-weight: 800;">{{item.userNickname}}</view>
					<view style="color: #888888;font-size: 22upx;margin-top: 10upx;">{{item.createTime}}</view>
				</view>
			</view>
			<text style="margin-top: 20upx;color: #333333;line-height: 40upx;">
				{{item.content}}
			</text>
			<view style="flex-wrap: wrap;">
				<image @tap="preview(index,item.images)" v-for="(img ,index) in item.images" :key="index" :src="img" :class="[index%3==0?'':'margin_left']"
				 style="height: 200upx;width: 200upx;margin-top: 20upx;" mode="aspectFill" lazy-load></image>
			</view>
		</view>
	</view>
</template>

<script>
	import api from '../../common/api.js';
	import {
		getWithParam_
	} from '../../common/request.js';
	export default {
		data() {
			return {
				index: 1,
				pageSize: 10,
				findList: [],
				loadMore: true
			}
		},
		onLoad() {
			this.initData()
		},
		onPullDownRefresh() {
			this.loadMore = true
			this.index = 1
			this.findList = []
			this.initData()
		},
		onReachBottom() {
			if (this.loadMore) {
				this.index = this.index + 1
				this.initData()
			}
		},
		methods: {
			preview(index,data) {
				uni.previewImage({
					urls: data,
					current:index
				})
			},
			initData() {
				getWithParam_(api.FIND_LIST, {
					index: this.index,
					pageSize: this.pageSize
				}).then(res => {
					uni.stopPullDownRefresh()
					if (res.data.length < 10) {
						this.loadMore = false
					}
					this.findList = this.findList.concat(res.data)
				})
			}
		}
	}
</script>

<style>
	.margin_left {
		margin-left: 15upx;
	}
</style>
